<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类内部的工作机制</title>
</head>
<body>
    <script>
        class User{
            constructor(name){
                this.name = name;
            }
            show(){
                console.log(this.name);
            }
        }
        let user = new User('xiasnn');
        user.show();

        console.dir(User);
        console.log(User.prototype.constructor == User);
        console.log(Object.getOwnPropertyNames(User.prototype));
        console.log(Object.getOwnPropertyNames(user));


        // 相当于
        function Hd(name){
            this.name = name;
        }
        Hd.prototype.show = function(){
            console.log(this.name);
        }
        let hd = new Hd("后盾人");
        hd.show();

        console.dir(Hd);
        console.log(Hd.prototype.constructor == Hd);
        console.log(Object.getOwnPropertyNames(Hd.prototype));
        console.log(Object.getOwnPropertyNames(hd));
    </script>
</body>
</html>